<!--  -->
<template>
<div class='label-page'>
  <van-popup 
    v-model="addTagPop" 
    position="bottom" 
    @close="downTagPop" 
    :style="{ borderRadius: '10px 10px 0 0' }"
    ref="addTagRef"
    :lock-scroll="false"
    :lazy-render="false"
    @opened="addOpened">
    <div class="add-tag-main">
      <h3>添加标签</h3>
      <p class="desc">添加后，该用户自动打上该标签！！</p>
      <div class="add-tag-form">
        <div class="tag-input flex-a-c">
          <div class="name">标签名</div>
          <el-input v-model="tagKeyWord" placeholder="请输入内容" @change="tagChange"></el-input>
        </div>
        <div class="tag-group flex">
          <div class="name">标签组</div>
          <div class="group-list " ref="groupTagList">
            <div class="group-list-main flex">
              <div class="group-btn" :class="groupIndex === index?'on':''" v-for="(item,index) in groupList" :key="index" @click="groupClick(item,index)">{{item.group_name}}</div>
            </div>
            <span id="addLoadMore" style="display: inline-block; width: 100%; height: 5rem;"></span>
          </div>
        </div>
      </div>
      <div class="m-100"></div>
      <div class="footer-btn flex-a-c flex-j-sb">
        <div class="footer-cancel" @click.stop="downTagPop">取消</div>
        <div class="footer-confirm" @click="addConfirmOn">添加</div>
      </div>
    </div>
  </van-popup>
</div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';

export default {
name:'',
//import引入的组件需要注入到对象中才能使用
components: {},
props:['addTagPop','groupList'],
data() {
return {
  tagKeyWord:'',
  groupId:'',
  groupIndex:0
};
},
//监听属性 类似于data概念
computed: {},
//监控data中的数据变化
watch: {},
//方法集合
methods: {
  downTagPop() {
    this.$emit('update:addTagPop', this.addTagPop=false);
  },
  addConfirmOn() {
    if(!this.tagKeyWord) {
      return this.$toast('请输入标签');
    } 
    this.$emit('addConfirmOn', {tagKeyWord:this.tagKeyWord,index:this.groupIndex,groupId:this.groupId})
  },
  addOpened() {
    if(this.$refs.addTagRef){
      this.$parent.addOpened();
    }
  },
  groupClick(item,index) {
    this.groupIndex = index;
    this.groupId = item.group_id;
    
  }
},
//生命周期 - 创建完成（可以访问当前this实例）
created() {
  
},
//生命周期 - 挂载完成（可以访问DOM元素）
mounted() {

},
beforeCreate() {}, //生命周期 - 创建之前
beforeMount() {}, //生命周期 - 挂载之前
beforeUpdate() {}, //生命周期 - 更新之前
updated() {}, //生命周期 - 更新之后
beforeDestroy() {}, //生命周期 - 销毁之前
destroyed() {}, //生命周期 - 销毁完成
activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
<style scoped>
.label-page {
  position: relative;
}
.add-tag-main ::v-deep .group-list {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE 10+ */
}
.add-tag-main ::v-deep .group-list::-webkit-scrollbar {
  display: none; /* Chrome Safari */
}
</style>
<style lang="scss" scoped>
/* @import url(); 引入公共css类 */
.m-100 {
  height: 100px;
  clear: both;
}
.add-tag-main {
  padding:21px 12px 13px 12px;
  h3 {
    font-size: 16px;
    font-weight: bold;
    color: #1B1B1B;
    padding:0 0 11px 0;
    text-align: left;
  }
  .desc {
    font-size: 12px;
    font-weight: 400;
    color: #F78B00;
    padding: 0 0 20px 0;
    text-align: left;
  }
  .add-tag-form {
    .tag-input,.tag-group {
      .name {
        font-size: 13px;
        color: #1B1B1B;
        white-space: nowrap;
        padding-right: 13px;
      }
    }
    .tag-group {
      padding:13px 0 0 0;
      .group-list {
        height: 50vh;
        overflow: hidden;
        .group-list-main {
          flex-wrap: wrap;
        }
        .group-btn {
          font-size: 12px;
          line-height: 12px;
          padding:9px 30px;
          min-width: 94px;
          border: 1px solid #D0D0D0;
          border-radius: 4px;
          margin:0 10px 10px 0;
          // &:nth-child(3n) {
          //   margin:0  0px 10px 0;
          // }
        }
        .on {
          border: 1px solid #F78B00;
          color:#F78B00;
        }
      }
      
    }
  }
  .footer-btn {
    width: 100%;
    background-color: #fff;
    box-sizing: border-box;
    position: fixed;
    bottom: 16px;
    left:0;
    padding:10px 15px;
    .footer-cancel {
      font-size: 14px;
      color: #1B1B1B;
      width: calc((100% - 10px*2)/2);
      
      padding:12px 0px;
      border: 1px solid #D0D0D0;
      border-radius: 20px;
    }
    .footer-confirm {
      font-size: 14px;
      color: #FFFFFF;
      font-weight: 500;
      width: calc((100% - 10px*2)/2);
      background: #F78B00;
      padding:12px 0px;
      border-radius: 20px;
      // padding:12px 58px;
    }
  }
}
</style>